import request from '@/utils/request'

// 获取菜品列表
export function getDishList(params) {
  return request({
    url: '/api/dish/list',
    method: 'get',
    params
  })
}

// 根据ID获取菜品详情
export function getDishById(id) {
  return request({
    url: `/api/dish/${id}`,
    method: 'get'
  })
}

// 新增菜品
export function addDish(data) {
  return request({
    url: '/api/dish/add',
    method: 'post',
    data
  })
}

// 更新菜品
export function updateDish(data) {
  return request({
    url: '/api/dish/update',
    method: 'put',
    data
  })
}

// 删除菜品
export function deleteDish(id) {
  return request({
    url: `/api/dish/delete/${id}`,
    method: 'delete'
  })
}

// 更新菜品状态
export function updateDishStatus(id, status) {
  return request({
    url: `/api/dish/status/${id}`,
    method: 'put',
    params: { status }
  })
}

// 设置推荐菜品
export function setFeatured(id, isFeatured) {
  return request({
    url: `/api/dish/featured/${id}`,
    method: 'put',
    params: { isFeatured }
  })
}

// 更新库存状态
export function updateInventory(id, available) {
  return request({
    url: `/api/dish/inventory/${id}`,
    method: 'put',
    params: { available }
  })
}